package taskcards;

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.Arrays;

import javax.accessibility.AccessibleContext;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.filechooser.FileSystemView;
import javax.swing.filechooser.FileView;
import java.awt.font.*;

public class InteractiveTaskCardsGUI extends JPanel implements ActionListener {
	private JTextArea nameBox, aboutText, terminal1, terminal1a, terminal2,
			terminal3, terminal4, terminal5, terminal6, activity1Box,
			activity2Box, activity3Box, activity4Box, activity5Box;
	
	// TEXT AREAS FOR TITLE BOXES FOR EACH ACTIVITY
	private JTextArea titleBox1, titleBox2, titleBox3, titleBox4, titleBox5;
	JLabel tertleberx1, tertleberx2, tertleberx3, tertleberx4, tertleberx5;
	
	JPanel pagesPanel;
	JLabel name, title1, title1b, title2, title3, title4, title5, title6,
			title7, title8;
	JList listFiles;
	JComboBox listFonts, listFonts2, listFonts3, listFonts4, listFonts5;
	JButton resume, startNew, next0, next0a, next1, next2, next1b, previous1b,
			next3, next4, next5, next6, next7, previous0, previous0a,
			previous1, previous2, previous3, previous4, previous5, previous6,
			previous7, previous8, insertFacePic, insertPicButton1,
			insertPicButton2, insertVideoButton2, insertPicButton3,
			insertVideoButton1, insertVideoButton3, insertPicButton4,
			insertVideoButton4, insertPicButton5, insertVideoButton5, button1,
			button2, button3, button4, button5, actInst1, actInst2, actInst3,
			actInst4, actInst5, saveExit, export, insertLink1, fontButton1,
			insertLink2, insertLink3, insertLink4, insertLink5,embedWebButton1,embedWebButton2,embedWebButton3,embedWebButton4,embedWebButton5;
	CardLayout fullLayout;
	String fileName = "";
	String act1file, act2file, act3file, act4file, act5file;
	JList selectionList;
	Object[] data;
	JFileChooser choosefile1, choosefile2, choosefile3, choosefile4,
			choosefile5, choosefile6, chooseVid1, chooseVid2, chooseVid3,
			chooseVid4, chooseVid5;
	int numActivities = 1;
	boolean resumetask = false;
	int numImages = 0;

	int defaultWidth = 590;
	int defaultHeight = 507;

	InteractiveTaskCard t1;
	
	

	public void addComponent(Container pane) {

		fullLayout = new CardLayout();
		pagesPanel = new JPanel(fullLayout);

		// /////////////////////////////////////////////////////
		// Create title page 1a(Title)
		JPanel pg1a = new JPanel();
		// Background
		// pg1a.setBackground(new Color(0, 0, 0));
		pg1a.setLayout(new BoxLayout(pg1a, BoxLayout.PAGE_AXIS));
		JLabel title1a = new JLabel("Interactive Task Cards");
		title1a.setFont(new Font("Verdana", Font.BOLD, 20));
		// title1a.setForeground(new Color(0, 191, 255));
		title1a.setForeground(Color.BLUE);
		JLabel question = new JLabel("What would you like to do?");
		question.setFont(new Font("Verdana", Font.BOLD, 15));
		// question.setForeground(new Color(200, 200, 255));
		question.setForeground(Color.BLACK);
		title1a.setAlignmentX(CENTER_ALIGNMENT);
		question.setAlignmentX(CENTER_ALIGNMENT);
		JPanel prettyButtonP = new JPanel();
		prettyButtonP.setLayout(new FlowLayout(FlowLayout.CENTER));
		// prettyButtonP.setBackground(Color.BLACK);
		resume = new JButton("Resume Task Card");
		resume.addActionListener(this);
		startNew = new JButton("Create New Task Card");
		startNew.addActionListener(this);

		prettyButtonP.add(resume);
		prettyButtonP.add(Box.createRigidArea(new Dimension(15, 0)));
		prettyButtonP.add(startNew);

		pg1a.add(Box.createRigidArea(new Dimension(0, 15)));
		pg1a.add(title1a);
		pg1a.add(Box.createRigidArea(new Dimension(0, 80)));
		pg1a.add(question);
		pg1a.add(prettyButtonP);

		// ///////////////////////////////////////////////////////////
		// Create resume page 1b(resume)
		JPanel pg1b = new JPanel();
		pg1b.setLayout(new BoxLayout(pg1b, BoxLayout.PAGE_AXIS));
		JLabel title1b = new JLabel("Select File to Resume:");
		title1b.setAlignmentX(CENTER_ALIGNMENT);
		title1b.setFont(new Font("Verdana", Font.BOLD, 20));
		title1b.setForeground(Color.BLUE);
		JPanel prettyButtonP2 = new JPanel();
		prettyButtonP2.setLayout(new FlowLayout(FlowLayout.LEFT));
		// Poppulate the list with all of the files
		File taskCardDir = new File(".//TaskCards");
		String[] children = taskCardDir.list();

		listFiles = new JList(children);


		JScrollPane logScrollPane1b = new JScrollPane(listFiles,
				JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
				JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

		next0a = new JButton("Next");
		next0a.addActionListener(this);
		previous0a = new JButton("Previous");
		previous0a.addActionListener(this);

		prettyButtonP2.add(previous0a);

		prettyButtonP2.add(Box.createRigidArea(new Dimension(280, 0)));
		prettyButtonP2.add(next0a);
		pg1b.add(Box.createRigidArea(new Dimension(0, 25)));
		pg1b.add(title1b);
		pg1b.add(Box.createRigidArea(new Dimension(0, 25)));
		pg1b.add(logScrollPane1b);
		pg1b.add(Box.createRigidArea(new Dimension(0, 10)));
		pg1b.add(prettyButtonP2);

		// /////////////////////////////////////////////////////
		// Create the page1
		JPanel pg1 = new JPanel();
		pg1.setLayout((new BoxLayout(pg1, BoxLayout.PAGE_AXIS)));
		JPanel prettyPanel1 = new JPanel();
		name = new JLabel("Enter your first and last name:");
		name.setAlignmentX(CENTER_ALIGNMENT);
		name.setFont(new Font("Verdana", Font.BOLD, 17));
		name.setForeground(Color.BLUE);
		nameBox = new JTextArea(3, 3);
		nameBox.setAlignmentX(CENTER_ALIGNMENT);
		nameBox.setBackground(Color.GRAY);
	
		next0 = new JButton("Next");
		next0.addActionListener(this);
		previous0 = new JButton("Previous");
		previous0.addActionListener(this);

		prettyPanel1.add(previous0);
		prettyPanel1.add(Box.createRigidArea(new Dimension(280, 0)));
		prettyPanel1.add(next0);
		nameBox.setEditable(true);
		nameBox.setMaximumSize(new Dimension(150, 0));

		// add a terminal1a
		terminal1a = new JTextArea(3, 50);
		terminal1a.setMargin(new Insets(10, 10, 10, 10));
		terminal1a.setEditable(false);

		JScrollPane logScrollPane1a = new JScrollPane(terminal1a);
		logScrollPane1a
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
		pg1.add(Box.createRigidArea(new Dimension(0, 20)));
		pg1.add(name);
		pg1.add(Box.createRigidArea(new Dimension(0, 40)));
		pg1.add(nameBox);
		pg1.add(Box.createRigidArea(new Dimension(0, 150)));
		pg1.add(prettyPanel1);
		pg1.add(logScrollPane1a);

		// //////////////////////////////////////////////////////
		// Create the page2
		JPanel pg2 = new JPanel();
		pg2.setLayout(new BoxLayout(pg2, BoxLayout.PAGE_AXIS));
		// pg2.setBackground(Color.BLACK);
		JPanel prettyPanel2 = new JPanel();
		FlowLayout design = new FlowLayout(FlowLayout.LEFT);
		prettyPanel2.setLayout(design);
		// prettyPanel2.setBackground(Color.BLACK);
		title1 = new JLabel("   Insert Your Picture:");
		title1.setAlignmentX(CENTER_ALIGNMENT);
		title1.setFont(new Font("Verdana", Font.BOLD, 17));
		// title1.setForeground(new Color(0, 191, 255));
		//title1.setForeground(Color.BLUE);
		java.net.URL img = InteractiveTaskCardsGUI.class
				.getResource("person.png");
		ImageIcon image = new ImageIcon(img);

		insertFacePic = new JButton("Open File...", image);
		insertFacePic.setBackground(Color.blue);
		insertFacePic.setAlignmentX(CENTER_ALIGNMENT);
		insertFacePic.addActionListener(this);
		previous1 = new JButton("Previous");
		previous1.addActionListener(this);
		next1 = new JButton("Next");
		next1.addActionListener(this);

		// add a terminal1
		terminal1 = new JTextArea(3, 50);
		terminal1.setMargin(new Insets(5, 5, 5, 5));
		terminal1.setEditable(false);
		JScrollPane logScrollPane1 = new JScrollPane(terminal1);
		logScrollPane1
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
		logScrollPane1
				.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
		choosefile1 = new JFileChooser();
		choosefile1.setSelectedFile(null);
		FileNameExtensionFilter filter1 = new FileNameExtensionFilter(
				"Images Only", "jpg", "gif", "png");
		choosefile1.addChoosableFileFilter(filter1);
		choosefile1.setAcceptAllFileFilterUsed(false);
		choosefile1.setFileFilter(filter1);

		prettyPanel2.add(previous1);
		prettyPanel2.add(Box.createRigidArea(new Dimension(280, 0)));
		prettyPanel2.add(next1);

		pg2.add(Box.createRigidArea(new Dimension(0, 20)));
		pg2.add(title1);
		pg2.add(Box.createRigidArea(new Dimension(0, 50)));
		pg2.add(insertFacePic);
		pg2.add(Box.createRigidArea(new Dimension(0, 150)));
		pg2.add(logScrollPane1);
		pg2.add(prettyPanel2);

		// ///////////////////////////////////////////////////////
		// Create page2b
		JPanel pg2b = new JPanel();
		pg2b.setLayout(new BoxLayout(pg2b, BoxLayout.PAGE_AXIS));
		JPanel prettyPanel2b = new JPanel();
		prettyPanel2b.setLayout(design);
		title1b = new JLabel("   About Me:");
		title1b.setAlignmentX(CENTER_ALIGNMENT);
		title1b.setFont(new Font("Verdana", Font.BOLD, 17));
		title1b.setForeground(Color.BLUE);

		previous1b = new JButton("Previous");
		previous1b.addActionListener(this);
		next1b = new JButton("Next");
		next1b.addActionListener(this);

		prettyPanel2b.add(previous1b);

		prettyPanel2b.add(Box.createRigidArea(new Dimension(280, 0)));
		prettyPanel2b.add(next1b);

		aboutText = new JTextArea(100, 100);
		aboutText.setEditable(true);
		aboutText.setLineWrap(true);
		JScrollPane aboutScrollPane = new JScrollPane(aboutText);
		aboutScrollPane
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

		pg2b.add(title1b);
		pg2b.add(Box.createRigidArea(new Dimension(0, 20)));
		pg2b.add(aboutScrollPane);

		pg2b.add(prettyPanel2b);

		// ///////////////////////////////////////////////////////
		// Create page3
		JPanel pg3 = new JPanel();
		pg3.setLayout(new BoxLayout(pg3, BoxLayout.PAGE_AXIS));
		title2 = new JLabel("How Many Activities Would You Like To Create?");
		title2.setAlignmentX(CENTER_ALIGNMENT);
		title2.setFont(new Font("Verdana", Font.BOLD, 15));
		title2.setForeground(Color.BLACK);
		JPanel prettyPanel3 = new JPanel();
		FlowLayout design2 = new FlowLayout(FlowLayout.CENTER);
		prettyPanel3.setLayout(design2);
		JPanel prettyPanel4 = new JPanel();
		prettyPanel4.setLayout(design);

		// Add the selection buttons
		button1 = new JButton("1");
		button1.setMargin(new Insets(20, 20, 20, 20));
		button1.addActionListener(this);
		button2 = new JButton("2");
		button2.setMargin(new Insets(20, 20, 20, 20));
		button2.addActionListener(this);
		button3 = new JButton("3");
		button3.setMargin(new Insets(20, 20, 20, 20));
		button3.addActionListener(this);
		button4 = new JButton("4");
		button4.setMargin(new Insets(20, 20, 20, 20));
		button4.addActionListener(this);
		button5 = new JButton("5");
		button5.setMargin(new Insets(20, 20, 20, 20));
		button5.addActionListener(this);
		previous2 = new JButton("Previous");
		previous2.addActionListener(this);

		prettyPanel3.add(button1);
		prettyPanel3.add(button2);
		prettyPanel3.add(button3);
		prettyPanel3.add(button4);
		prettyPanel3.add(button5);
		prettyPanel4.add(previous2);

		pg3.add(Box.createRigidArea(new Dimension(0, 20)));
		pg3.add(title2);
		pg3.add(Box.createRigidArea(new Dimension(0, 70)));
		pg3.add(prettyPanel3);
		pg3.add(Box.createRigidArea(new Dimension(0, 190)));
		pg3.add(prettyPanel4);

		// Activity 1

		Font font = new Font(Font.SANS_SERIF, Font.BOLD, 17);
		JPanel pg4 = new JPanel();
		pg4.setLayout(new BoxLayout(pg4, BoxLayout.PAGE_AXIS));
		Color defaultColor = pg4.getBackground();
		chooseVid1 = new JFileChooser();
		title3 = new JLabel("Activity1");
		title3.setAlignmentX(CENTER_ALIGNMENT);
		title3.setFont(font);
		title3.setForeground(Color.BLUE);
		JPanel prettyPanel5 = new JPanel();
		prettyPanel5.setLayout(design);

		// Set up the font and link and size buttons
		JPanel toolbarPanel1 = new JPanel();
		toolbarPanel1.setLayout(design);

		insertLink1 = new JButton("Insert Link");
		insertLink1.addActionListener(this);
 
		String[] fonts = { "Arial", "Times New Roman", "Some other Font" };

		// HEADER TITLE
		tertleberx1 = new JLabel("Header: ");
		tertleberx1.setForeground(Color.WHITE);
		toolbarPanel1.add(tertleberx1);
		
		// TEXT BOX 1
		titleBox1 = new JTextArea(1, 12);
		toolbarPanel1.add(titleBox1);
		
		//listFonts = new JComboBox(fonts);
		//listFonts.addActionListener(this);
		//toolbarPanel1.add(listFonts);
		
		toolbarPanel1.add(insertLink1);

		toolbarPanel1.setBackground(Color.darkGray);

		// Add the activity text box for storing information
		activity1Box = new JTextArea(12, 12);

		activity1Box.setLineWrap(true);

		JScrollPane scrollPane2 = new JScrollPane(activity1Box);
		scrollPane2
				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		// Other boxes
		insertPicButton1 = new JButton("Insert Picture...");
		insertPicButton1.addActionListener(this);

		insertVideoButton1 = new JButton("YouTube/Map");
		insertVideoButton1.addActionListener(this);
		
		embedWebButton1 = new JButton(" Embed Website");
		embedWebButton1.addActionListener(this);
		JPanel buttonPanel = new JPanel();
	
		buttonPanel.add(embedWebButton1);
		buttonPanel.add(insertPicButton1);
		buttonPanel.add(insertVideoButton1);
		buttonPanel.setBackground(Color.darkGray);

		previous3 = new JButton("Previous");
		previous3.addActionListener(this);
		next3 = new JButton("Next");
		next3.addActionListener(this);

		// add terminal2
		// add a terminal1
		terminal2 = new JTextArea(3, 50);
		terminal2.setMargin(new Insets(5, 5, 5, 5));
		terminal2.setEditable(false);
		terminal2.setBackground(defaultColor);
		JScrollPane logScrollPane2 = new JScrollPane(terminal2);

		logScrollPane2
				.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
		logScrollPane2
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

		choosefile2 = new JFileChooser();
		choosefile2.addChoosableFileFilter(filter1);
		choosefile2.setAcceptAllFileFilterUsed(false);
		choosefile2.setFileFilter(filter1);

		prettyPanel5.add(previous3);
		prettyPanel5.add(Box.createRigidArea(new Dimension(270, 0)));
		prettyPanel5.add(next3);
		prettyPanel5.setBackground(defaultColor);

		pg4.add(Box.createRigidArea(new Dimension(0, 5)));
		pg4.add(title3);
		pg4.add(Box.createRigidArea(new Dimension(0, 5)));
		pg4.add(toolbarPanel1);
		pg4.add(scrollPane2);
		pg4.add(buttonPanel);
		pg4.add(prettyPanel5);
		pg4.add(logScrollPane2);

		// //////////////////////////////////////////////////
		// /////////////////////////////////////////////////////
		// Create Page 5 (Activity2)
		JPanel pg5 = new JPanel();
		pg5.setLayout(new BoxLayout(pg5, BoxLayout.PAGE_AXIS));
		chooseVid2 = new JFileChooser();
		title4 = new JLabel("Activity2");
		title4.setAlignmentX(CENTER_ALIGNMENT);
		title4.setFont(font);
		title4.setForeground(Color.BLUE);
		JPanel prettyPanel6 = new JPanel();
		prettyPanel6.setLayout(design);
		
		// Add the activity text box for storing information
		activity2Box = new JTextArea(12, 12);
		activity2Box.setLineWrap(true);
		JScrollPane scrollPane3 = new JScrollPane(activity2Box);
		scrollPane3
				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

		// Other boxes
		insertPicButton2 = new JButton("Insert Picture...");
		insertPicButton2.addActionListener(this);
		insertPicButton2.setAlignmentX(CENTER_ALIGNMENT);
		insertVideoButton2 = new JButton("YouTube/Map");
		insertVideoButton2.addActionListener(this);
		insertVideoButton2.setAlignmentX(CENTER_ALIGNMENT);
		previous4 = new JButton("Previous");
		previous4.addActionListener(this);
		next4 = new JButton("Next");
		next4.addActionListener(this);

		// Set up the font and link and size buttons
		JPanel toolbarPanel2 = new JPanel();
		toolbarPanel2.setLayout(design);

		tertleberx2 = new JLabel("Header: ");
		tertleberx2.setForeground(Color.WHITE);
		toolbarPanel2.add(tertleberx2);
		titleBox2 = new JTextArea(1, 12);
		toolbarPanel2.add(titleBox2);
		
		insertLink2 = new JButton("Insert Link");
		insertLink2.addActionListener(this);

		//listFonts2 = new JComboBox(fonts);
		//listFonts2.addActionListener(this);
		
		embedWebButton2 = new JButton(" Embed Website");
		embedWebButton2.addActionListener(this);

		//toolbarPanel2.add(listFonts2);
		toolbarPanel2.add(insertLink2);

		toolbarPanel2.setBackground(Color.darkGray);

		// Button Panel
		JPanel buttonPanel2 = new JPanel();
		buttonPanel2.setAlignmentX(CENTER_ALIGNMENT);
		buttonPanel2.add(embedWebButton2);
		
		buttonPanel2.add(insertPicButton2);
		buttonPanel2.add(insertVideoButton2);
		buttonPanel2.setBackground(Color.darkGray);

		// add terminal3
		// add a terminal1
		terminal3 = new JTextArea(3, 50);
		terminal3.setMargin(new Insets(5, 5, 5, 5));
		terminal3.setEditable(false);
		JScrollPane logScrollPane3 = new JScrollPane(terminal3);
		choosefile3 = new JFileChooser();
		choosefile3.addChoosableFileFilter(filter1);
		choosefile3.setAcceptAllFileFilterUsed(false);
		choosefile3.setFileFilter(filter1);

		logScrollPane3
				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
		logScrollPane3
				.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

		prettyPanel6.add(previous4);
		prettyPanel6.add(Box.createRigidArea(new Dimension(270, 0)));
		prettyPanel6.add(next4);

		pg5.add(Box.createRigidArea(new Dimension(0, 5)));
		pg5.add(title4);
		pg5.add(Box.createRigidArea(new Dimension(0, 5)));
		pg5.add(toolbarPanel2);
		pg5.add(scrollPane3);
		pg5.add(buttonPanel2);
		pg5.add(prettyPanel6);
		pg5.add(logScrollPane3);

		// ////////////////////////////////////////////////////
		// /////////////////////////////////////////////////////
		// Create Page 6 (Activity3)
		JPanel pg6 = new JPanel();
		pg6.setLayout(new BoxLayout(pg6, BoxLayout.PAGE_AXIS));
		chooseVid3 = new JFileChooser();
		title5 = new JLabel("Activity3");
		title5.setAlignmentX(CENTER_ALIGNMENT);
		title5.setFont(font);
		title5.setForeground(Color.BLUE);
		JPanel prettyPanel7 = new JPanel();
		prettyPanel7.setLayout(design);


		// Add the activity text box for storing information
		activity3Box = new JTextArea(12, 12);
		activity3Box.setLineWrap(true);
		// activity3Box.setBackground(Color.BLACK);
		// activity3Box.setForeground(new Color(200, 200, 255));
		JScrollPane scrollPane4 = new JScrollPane(activity3Box);
		scrollPane4
				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		// Other boxes
		insertPicButton3 = new JButton("Insert Picture...");
		insertPicButton3.addActionListener(this);
		insertPicButton3.setAlignmentX(CENTER_ALIGNMENT);
		insertVideoButton3 = new JButton("YouTube/Map");
		insertVideoButton3.addActionListener(this);
		insertVideoButton3.setAlignmentX(CENTER_ALIGNMENT);
		previous5 = new JButton("Previous");
		previous5.addActionListener(this);
		next5 = new JButton("Next");
		next5.addActionListener(this);

		// Set up the font and link and size buttons
		JPanel toolbarPanel3 = new JPanel();
		toolbarPanel3.setLayout(design);

		tertleberx3 = new JLabel("Header: ");
		tertleberx3.setForeground(Color.WHITE);
		toolbarPanel3.add(tertleberx3);
		
		titleBox3 = new JTextArea(1, 12);
		toolbarPanel3.add(titleBox3);
		
		insertLink3 = new JButton("Insert Link");
		insertLink3.addActionListener(this);

		//listFonts3 = new JComboBox(fonts);
		//listFonts3.addActionListener(this);
		
		embedWebButton3 = new JButton(" Embed Website");
		embedWebButton3.addActionListener(this);

		//toolbarPanel3.add(listFonts3);
		toolbarPanel3.add(insertLink3);

		toolbarPanel3.setBackground(Color.darkGray);

		// Button Panel
		JPanel buttonPanel3 = new JPanel();
		buttonPanel3.setAlignmentX(CENTER_ALIGNMENT);
		buttonPanel3.add(embedWebButton3);
		buttonPanel3.add(insertPicButton3);
		buttonPanel3.add(insertVideoButton3);
		buttonPanel3.setBackground(Color.darkGray);

		// add terminal3
		// add a terminal1
		terminal4 = new JTextArea(3, 50);
		terminal4.setMargin(new Insets(5, 5, 5, 5));
		terminal4.setEditable(false);
		JScrollPane logScrollPane4 = new JScrollPane(terminal4);
		logScrollPane4
				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
		logScrollPane4
				.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		choosefile4 = new JFileChooser();
		choosefile4.addChoosableFileFilter(filter1);
		choosefile4.setAcceptAllFileFilterUsed(false);
		choosefile4.setFileFilter(filter1);

		prettyPanel7.add(previous5);
		prettyPanel7.add(Box.createRigidArea(new Dimension(270, 0)));
		prettyPanel7.add(next5);

		pg6.add(Box.createRigidArea(new Dimension(0, 5)));
		pg6.add(title5);
		pg6.add(Box.createRigidArea(new Dimension(0, 5)));
		pg6.add(toolbarPanel3);
		pg6.add(scrollPane4);
		pg6.add(buttonPanel3);
		pg6.add(prettyPanel7);
		pg6.add(logScrollPane4);

		// ////////////////////////////////////////////////////
		// /////////////////////////////////////////////////////
		// Create Page 7 (Activity4)
		JPanel pg7 = new JPanel();
		pg7.setLayout(new BoxLayout(pg7, BoxLayout.PAGE_AXIS));
		chooseVid4 = new JFileChooser();
		title6 = new JLabel("Activity4");
		title6.setAlignmentX(CENTER_ALIGNMENT);
		title6.setFont(font);
		title6.setForeground(Color.BLUE);
		JPanel prettyPanel8 = new JPanel();
		prettyPanel8.setLayout(design);

		// Add the activity text box for storing information
		activity4Box = new JTextArea(12, 12);
		activity4Box.setLineWrap(true);
		// activity4Box.setBackground(Color.BLACK);
		// activity4Box.setForeground(new Color(200, 200, 255));
		JScrollPane scrollPane5 = new JScrollPane(activity4Box);
		scrollPane5
				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		// Other boxes
		insertPicButton4 = new JButton("Insert Picture...");
		insertPicButton4.addActionListener(this);
		insertPicButton4.setAlignmentX(CENTER_ALIGNMENT);
		insertVideoButton4 = new JButton("YouTube/Map");
		insertVideoButton4.addActionListener(this);
		insertVideoButton4.setAlignmentX(CENTER_ALIGNMENT);
		previous6 = new JButton("Previous");
		previous6.addActionListener(this);
		next6 = new JButton("Next");
		next6.addActionListener(this);

		// Set up the font and link and size buttons
		JPanel toolbarPanel4 = new JPanel();
		toolbarPanel4.setLayout(design);
		
		// TITLE BOX 4
		tertleberx4 = new JLabel("Header: ");
		tertleberx4.setForeground(Color.WHITE);
		toolbarPanel4.add(tertleberx4);
		titleBox4 = new JTextArea(1, 12);
		toolbarPanel4.add(titleBox4);
		
		
		insertLink4 = new JButton("Insert Link");
		insertLink4.addActionListener(this);

		//listFonts4 = new JComboBox(fonts);
		//listFonts4.addActionListener(this);
		
		embedWebButton4 = new JButton(" Embed Website");
		embedWebButton4.addActionListener(this);

		//toolbarPanel4.add(listFonts4);
		toolbarPanel4.add(insertLink4);

		toolbarPanel4.setBackground(Color.darkGray);

		// Button Panel
		JPanel buttonPanel4 = new JPanel();
		buttonPanel4.setAlignmentX(CENTER_ALIGNMENT);
		buttonPanel4.add(embedWebButton4);
		buttonPanel4.add(insertPicButton4);
		buttonPanel4.add(insertVideoButton4);
		buttonPanel4.setBackground(Color.darkGray);

		// add terminal3
		// add a terminal1
		terminal5 = new JTextArea(3, 50);
		terminal5.setMargin(new Insets(5, 5, 5, 5));
		terminal5.setEditable(false);
		JScrollPane logScrollPane5 = new JScrollPane(terminal5);
		logScrollPane5
				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
		logScrollPane5
				.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		choosefile5 = new JFileChooser();
		choosefile5.addChoosableFileFilter(filter1);
		choosefile5.setAcceptAllFileFilterUsed(false);
		choosefile5.setFileFilter(filter1);

		prettyPanel8.add(previous6);
		prettyPanel8.add(Box.createRigidArea(new Dimension(270, 0)));
		prettyPanel8.add(next6);

		pg7.add(Box.createRigidArea(new Dimension(0, 5)));
		pg7.add(title6);
		pg7.add(Box.createRigidArea(new Dimension(0, 5)));
		pg7.add(toolbarPanel4);
		pg7.add(scrollPane5);
		pg7.add(buttonPanel4);
		pg7.add(prettyPanel8);
		pg7.add(logScrollPane5);

		// ////////////////////////////////////////////////////

		// /////////////////////////////////////////////////////
		// Create Page 8 (Activity5)
		JPanel pg8 = new JPanel();
		// pg8.setBackground(Color.BLACK);
		pg8.setLayout(new BoxLayout(pg8, BoxLayout.PAGE_AXIS));
		chooseVid5 = new JFileChooser();
		title7 = new JLabel("Activity5");
		title7.setAlignmentX(CENTER_ALIGNMENT);
		title7.setFont(font);
		// title7.setForeground(new Color(0, 191, 255));
		title7.setForeground(Color.BLUE);
		JPanel prettyPanel9 = new JPanel();
		prettyPanel9.setLayout(design);
		// prettyPanel9.setBackground(Color.BLACK);

		// Add the activity text box for storing information
		activity5Box = new JTextArea(12, 12);
		activity5Box.setLineWrap(true);
		// activity5Box.setBackground(Color.BLACK);
		// activity5Box.setForeground(new Color(200, 200, 255));
		JScrollPane scrollPane6 = new JScrollPane(activity5Box);
		scrollPane6
				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		// Other boxes
		insertPicButton5 = new JButton("Insert Picture...");
		insertPicButton5.addActionListener(this);
		insertPicButton5.setAlignmentX(CENTER_ALIGNMENT);
		insertVideoButton5 = new JButton("YouTube/Map");
		insertVideoButton5.addActionListener(this);
		insertVideoButton5.setAlignmentX(CENTER_ALIGNMENT);
		previous7 = new JButton("Previous");
		previous7.addActionListener(this);
		next7 = new JButton("Next");
		next7.addActionListener(this);

		// Set up the font and link and size buttons
		JPanel toolbarPanel5 = new JPanel();
		toolbarPanel5.setLayout(design);
		
		tertleberx5 = new JLabel("Header: ");
		tertleberx5.setForeground(Color.WHITE);
		toolbarPanel5.add(tertleberx5);
		titleBox5 = new JTextArea(1, 12);
		toolbarPanel5.add(titleBox5);

		insertLink5 = new JButton("Insert Link");
		insertLink5.addActionListener(this);

		//listFonts5 = new JComboBox(fonts);
		//listFonts5.addActionListener(this);
		
		embedWebButton5 = new JButton(" Embed Website");
		embedWebButton5.addActionListener(this);

		//toolbarPanel5.add(listFonts5);
		toolbarPanel5.add(insertLink5);
		toolbarPanel5.setBackground(Color.darkGray);

		// Button Panel
		JPanel buttonPanel5 = new JPanel();
		buttonPanel5.setAlignmentX(CENTER_ALIGNMENT);
		buttonPanel5.add(embedWebButton5);
		buttonPanel5.add(insertPicButton5);
		buttonPanel5.add(insertVideoButton5);
		buttonPanel5.setBackground(Color.darkGray);

		// add terminal3
		// add a terminal1
		terminal6 = new JTextArea(3, 50);
		terminal6.setMargin(new Insets(5, 5, 5, 5));
		terminal6.setEditable(false);
		JScrollPane logScrollPane6 = new JScrollPane(terminal6);
		logScrollPane6
				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
		logScrollPane6
				.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		choosefile6 = new JFileChooser();
		choosefile6.addChoosableFileFilter(filter1);
		choosefile6.setAcceptAllFileFilterUsed(false);
		choosefile6.setFileFilter(filter1);

		prettyPanel9.add(previous7);
		prettyPanel9.add(Box.createRigidArea(new Dimension(270, 0)));
		prettyPanel9.add(next7);

		pg8.add(Box.createRigidArea(new Dimension(0, 5)));
		pg8.add(title7);
		pg8.add(Box.createRigidArea(new Dimension(0, 5)));
		pg8.add(toolbarPanel5);
		pg8.add(scrollPane6);
		pg8.add(buttonPanel5);
		pg8.add(prettyPanel9);
		pg8.add(logScrollPane6);

		// ////////////////////////////////////////////////////
		// Page 9 (Completion page)
		JPanel pg9 = new JPanel();
		pg9.setLayout(new BoxLayout(pg9, BoxLayout.PAGE_AXIS));
		// pg9.setBackground(Color.BLACK);
		JPanel prettyPanel10 = new JPanel();
		prettyPanel10.setLayout(design2);
		// prettyPanel10.setBackground(Color.BLACK);

		JLabel blahblah = new JLabel(
				"You have completed an Interactive Task Card!");
		Font font2 = new Font("Verdana", Font.BOLD, 12);
		blahblah.setFont(font2);
		blahblah.setForeground(Color.GREEN);
		blahblah.setAlignmentX(CENTER_ALIGNMENT);

		JLabel blahblah2 = new JLabel("Are you ready to Export to HTML?");
		blahblah2.setFont(font2);
		blahblah2.setForeground(Color.GREEN);
		blahblah2.setAlignmentX(CENTER_ALIGNMENT);

		JLabel message = new JLabel(
				"*This file will be saved as <YourName>.html");
		message.setFont(new Font("Verdana", Font.PLAIN, 9));
		message.setAlignmentX(CENTER_ALIGNMENT);
		JLabel blahblah3 = new JLabel("N0?");
		previous8 = new JButton("Previous");
		JPanel prettyPanel11 = new JPanel();
		prettyPanel11.setLayout(design);
		previous8.addActionListener(this);

		blahblah3.setFont(font2);
		blahblah3.setForeground(Color.RED);

		saveExit = new JButton("Save & Exit");
		saveExit.addActionListener(this);
		export = new JButton("Export to HTML");
		export.addActionListener(this);
		export.setAlignmentX(CENTER_ALIGNMENT);
		saveExit.setAlignmentX(CENTER_ALIGNMENT);
		prettyPanel11.add(previous8);
		// prettyPanel11.setBackground(Color.BLACK);

		pg9.add(blahblah);
		pg9.add(blahblah2);
		pg9.add(Box.createRigidArea(new Dimension(0, 20)));
		pg9.add(export);
		pg9.add(message);
		pg9.add(Box.createRigidArea(new Dimension(0, 80)));
		pg9.add(blahblah3);
		pg9.add(Box.createRigidArea(new Dimension(0, 20)));
		pg9.add(saveExit);
		pg9.add(Box.createRigidArea(new Dimension(0, 150)));
		pg9.add(prettyPanel11);

		// pagesPanel
		pagesPanel.add(pg1a, "Page1a");
		pagesPanel.add(pg1b, "Page1b");
		pagesPanel.add(pg1, "Page1");
		pagesPanel.add(pg2, "Page2");
		pagesPanel.add(pg2b, "Page2b");
		pagesPanel.add(pg3, "Page3");
		pagesPanel.add(pg4, "Page4");
		pagesPanel.add(pg5, "Page5");
		pagesPanel.add(pg6, "Page6");
		pagesPanel.add(pg7, "Page7");
		pagesPanel.add(pg8, "Page8");
		pagesPanel.add(pg9, "Page9");

		// pane.add(pg1);
		pane.add(pagesPanel);

	}

	public static String[] parseMethod(String filename, int actNum) {
		int size = 4 + (actNum * 4); // 3 for name/pic/about, number of
										// activities * 4 (title/text/pic/vid)
		String items[];
		items = new String[size];
		String prefixes[] = { "NAME: ", "PicPath: ", "About Me: ",
				"NumberOfActivities: ", "Activity1Title: ", "Activity1Text: ",
				"Activity1PicPath: ", "Activity1VidPath:", "Activity2Title: ", "Activity2Text: ",
				"Activity2PicPath: ", "Activity2VidPath:", "Activity3Title: ", "Activity3Text: ",
				"Activity3PicPath: ", "Activity3VidPath:", "Activity4Title: ", "Activity4Text: ",
				"Activity4PicPath: ", "Activity4VidPath:", "Activity5Title: ", "Activity5Text: ",
				"Activity5PicPath: ", "Activity5VidPath: " };

		try {
			FileInputStream instream = new FileInputStream(filename);
			DataInputStream in = new DataInputStream(instream);
			BufferedReader buff = new BufferedReader(new InputStreamReader(in));
			String prefix;
			String noprefix = "";
			String strLine;
			// System.out.println("File name: " + filename + "\n");
			int i = 0;
			while ((strLine = buff.readLine()) != null) {
				// System.out.println(strLine);
				prefix = prefixes[i];
				noprefix = strLine.substring(strLine.indexOf(prefix)
						+ prefix.length());
				items[i] = noprefix;
				i++;
			}

		} catch (Exception e) {
			System.err.println("Error: " + e.getMessage());
		}

		return items;
	}

	String replaceWithStar(String temp) {
		temp = temp.replaceAll("[\n\r]", "*");
		return temp;
	}

	String replaceStarsWithNewLines(String temp) {
		temp = temp.replaceAll("[*]", "\n");
		return temp;
	}

	public int verifyFile(String filename) {

		filename = ".\\TaskCards\\" + filename;
		File file = new File(filename);

		if (!file.exists()) {
			return 1;
		}
		// ELSE FILE ALREADY EXISTS!!! oH NOOOO
		return 0;
	}

	// Jake's copy method

	public static void copyImage(String imgPath, String imgDestination,
			String imgName) {

		try {
			File inputFile = new File(imgPath);

			File outputFile = new File(imgDestination + imgName);

			FileInputStream in = new FileInputStream(inputFile);
			FileOutputStream out = new FileOutputStream(outputFile);
			int theChar;
			while ((theChar = in.read()) != -1) {
				out.write(theChar);
			}
			out.close();
			in.close();
			System.out.println("copy done!");
		} catch (Exception e) {
			System.err.println("BAD" + e);
		}

	}

	public String createDirectory(String dirName) {
		String desktop = System.getProperty("user.home");
		desktop += "\\Desktop\\";
		String path = desktop + dirName;
		boolean make = (new File(path)).mkdir();
		if (make) {
			return path;
		} else {
			return null;
		}
	}
	
	public boolean isValidFile(String path){
		File file = new File(path);
		return file.exists();
		
	}



   public static String convert(String whatever){
           //String result = "";
           String sub = "";
           int i = 0;
           while(i < whatever.length()){
               switch(whatever.charAt(i)){
               case 'Á': whatever = whatever.substring(0, i) + "&Aacute;" + whatever.substring(i + 1, whatever.length()); break;
               case '¿': whatever = whatever.substring(0, i) + "&iquest;" + whatever.substring(i + 1, whatever.length()); break;
               case 'É': whatever = whatever.substring(0, i) + "&Eacute;" + whatever.substring(i + 1, whatever.length()); break;
               case 'Í': whatever = whatever.substring(0, i) + "&Iacute;" + whatever.substring(i + 1, whatever.length()); break;
               case 'Ñ': whatever = whatever.substring(0, i) + "&Ntilde;" + whatever.substring(i + 1, whatever.length()); break;
               case 'Ó': whatever = whatever.substring(0, i) + "&Oacute;" + whatever.substring(i + 1, whatever.length()); break;
               case 'Ú': whatever = whatever.substring(0, i) + "&Uacute;" + whatever.substring(i + 1, whatever.length()); break;
               case 'Ü': whatever = whatever.substring(0, i) + "&Uuml;" + whatever.substring(i + 1, whatever.length()); break;
               case 'á': whatever = whatever.substring(0, i) + "&#225;" + whatever.substring(i + 1, whatever.length()); break;
               case 'é': whatever = whatever.substring(0, i) + "&eacute;" + whatever.substring(i + 1, whatever.length()); break;
               case 'í': whatever = whatever.substring(0, i) + "&iacute;" + whatever.substring(i + 1, whatever.length()); break;
               case 'ñ': whatever = whatever.substring(0, i) + "&ntilde;" + whatever.substring(i + 1, whatever.length()); break;
               case 'ó': whatever = whatever.substring(0, i) + "&oacute;" + whatever.substring(i + 1, whatever.length()); break;
               case 'ú': whatever = whatever.substring(0, i) + "&uacute;" + whatever.substring(i + 1, whatever.length()); break;
               case 'ü': whatever = whatever.substring(0, i) + "&uuml;" + whatever.substring(i + 1, whatever.length()); break;
               case '¡': whatever = whatever.substring(0, i) + "&iexcl;" + whatever.substring(i + 1, whatever.length()); break;
             
               }
               i++;
               System.out.println(whatever);
           }
           
           return whatever;
       }
	

	// What do we do on clicks
	public void actionPerformed(ActionEvent e) {
		int returnVal;
		String absolutePath;

		if (e.getSource() == startNew) {

			resumetask = false;
			terminal1a.setText("");
			fullLayout.show(pagesPanel, "Page1");
		} else if (e.getSource() == resume) {
			resumetask = true;
			fullLayout.show(pagesPanel, "Page1b");
		} else if (e.getSource() == previous0a) {
			fullLayout.show(pagesPanel, "Page1a");
		} else if (e.getSource() == next0a) {
			// THIS IS WHERE IM GETTING THE FILE STRING
			String s = (String) (listFiles.getSelectedValue());
			System.out.println("THIS IS THE PART I NEEED" + s);
			t1 = new InteractiveTaskCard(s);

			t1.addFileName(s);
			s = ".\\TaskCards\\" + s;

			// THIS IS BAD change this
			String[] temp = parseMethod(s, 5);
			if (temp[1].toString() != null) {
				aboutText.setText("");
				terminal1.setText("");
				System.out.println("You selected" + temp[3]);
				t1.numActivities = Integer.parseInt(temp[3]);
				numActivities = t1.numActivities;
				terminal1.append("You have already selected:\n" + temp[1]
						+ "\nClick above to open a different picture.\n");
				t1.picPath = temp[1];
			}

			switch (numActivities) {
			case 1:
				t1.createOne();
				break;
			case 2:
				t1.createTwo();
				break;
			case 3:
				t1.createThree();
				break;
			case 4:
				t1.createFour();
				break;
			case 5:
				t1.createFive();
				break;
			default:
			}
			String addNewLines = temp[2].toString();
			addNewLines = replaceStarsWithNewLines(addNewLines);

			aboutText.append(addNewLines);

			// Has activity1 text?
			if(temp[4] != null){
				titleBox1.setText("");
				titleBox1.append(temp[4]);
			}
			if (temp[5] != null) {
				activity1Box.setText("");
				System.out.println("Got to act 1");
				addNewLines = replaceStarsWithNewLines(temp[5].toString());
				activity1Box.append(addNewLines);
			}
			System.out.println("DID I GET HERE");
			terminal2.setText("");
			// Has an activity1 pic?
			if (temp[6] != null) {
				terminal2.append("You have already selected:"
						+ temp[6].toString() + ".\n");
				t1.act1.picPath = temp[6].toString();
			}
			if (temp[7] != null) {
				terminal2.append("You previously selected:"
						+ temp[7].toString() + ".\n");
				t1.act1.videoPath = temp[7].toString();
			}

			if(temp[8] != null){
				titleBox2.setText("");
				titleBox2.append(temp[8]);
			}
			if (temp[9] != null) {
				activity2Box.setText("");
				//System.out.println("TEST " + temp[9]);
				addNewLines = replaceStarsWithNewLines(temp[9].toString());
				activity2Box.append(addNewLines);
			}

				// Has an activity1 pic?
			terminal3.setText("");
			if (temp[10] != null) {
				if(isValidFile(temp[10])){
				terminal3.append("You have already selected:"
						+ temp[10].toString() + ".\n");
				t1.act2.picPath = temp[10].toString();
				}else{
					terminal3.append("You previously selected an image that has now been moved.\nPlease reselect an image.\n");
				}
			}
			if (temp[11] != null) {
				terminal3.append("You previously selected:"
						+ temp[11].toString() + ".\n");
				t1.act2.videoPath = temp[11].toString();
			}

			if(temp[12] != null){
				titleBox3.setText("");
				titleBox3.append(temp[12]);
			}
			if (temp[13] != null) {
				activity3Box.setText("");
				addNewLines = replaceStarsWithNewLines(temp[13].toString());
				activity3Box.append(addNewLines);
			}

			terminal4.setText("");
			// Has an activity1 pic?
			if (temp[14] != null) {
				if(isValidFile(temp[11])){
				terminal4.append("You have already selected:"
						+ temp[14].toString() + ".\n");
				t1.act3.picPath = temp[14].toString();
				}
				else{
					terminal4.append("You previously selected an image that has now been moved.\nPlease reselect an image.\n");
				}
			}
			if (temp[15] != null) {
				terminal4.append("You previously selected:"
						+ temp[15].toString() + ".\n");
				t1.act3.videoPath = temp[15].toString();
			}
			if(temp[16] != null){
				titleBox4.setText("");
				titleBox4.append(temp[16]);
			}
			if (temp[17] != null) {
				activity4Box.setText("");
				addNewLines = replaceStarsWithNewLines(temp[17].toString());
				activity4Box.append(addNewLines);
			}
			terminal5.setText("");
			// Has an activity1 pic?
			if (temp[18] != null) {
				if(isValidFile(temp[18])){
				terminal5.append("You have already selected:"
						+ temp[18].toString() + ".\n");
				t1.act4.picPath = temp[18].toString();
				}else{
					terminal5.append("You previously selected an image that has now been moved.\nPlease reselect an image.\n");
				}
			}
			if (temp[19] != null) {
				terminal5.append("You previously selected:"
						+ temp[19].toString() + ".\n");
				t1.act4.videoPath = temp[19].toString();
			}
			if(temp[20] != null){
				titleBox5.setText("");
				titleBox5.append(temp[20]);
			}
			if (temp[21] != null) {
				activity5Box.setText("");
				addNewLines = replaceStarsWithNewLines(temp[21].toString());
				activity5Box.append(addNewLines);
			}
			terminal6.setText("");
			// Has an activity1 pic?
			if (temp[22] != null) {
				if(isValidFile(temp[22])){
				terminal6.append("You have already selected:"
						+ temp[22].toString() + ".\n");
				t1.act5.picPath = temp[22].toString();
				}else{
					terminal6.append("You previously selected an image that has now been moved.\nPlease reselect an image.\n");
				}
				
			}
			if (temp[23] != null) {
				terminal6.append("You previously selected:"
						+ temp[23].toString() + ".\n");
				t1.act5.videoPath = temp[23].toString();
			}

			fullLayout.show(pagesPanel, "Page2");
		} else if (e.getSource() == previous0) {
			fullLayout.show(pagesPanel, "Page1a");
		}

		else if (e.getSource() == next0) {

			try {
				fileName = nameBox.getText();
				t1 = new InteractiveTaskCard(fileName);
			} catch (Exception err) {
				System.out.println(err);
			}
			if (t1.name.isEmpty()) {
				terminal1a.setText("");
				terminal1a
						.append("YOU MUST ENTER YOUR FULL NAME TO CONTINUE!\n");
				fullLayout.show(pagesPanel, "Page1");

			} else {
				fileName = fileName.replaceAll(" ", "");

				t1.addFileName(fileName);
				System.out.println(fileName);
				int result = verifyFile(fileName);

				if (result == 1) {
					// System.out.println("OKAY");
					terminal1.setText("");
					fullLayout.show(pagesPanel, "Page2");
				} else {
					System.out.println("File ALready exists");

					terminal1a
							.append("A file for "
									+ fileName
									+ " already exists!\nPlease Go back and Resume editing that File!\n");
					fullLayout.show(pagesPanel, "Page1");

				}
			}

		}

		else if (e.getSource() == previous1) {
			if (resumetask == false)
				fullLayout.show(pagesPanel, "Page1");
			else
				fullLayout.show(pagesPanel, "Page1b");
		}

		else if (e.getSource() == insertFacePic) {
			returnVal = choosefile1
					.showOpenDialog(InteractiveTaskCardsGUI.this);

			if (returnVal == JFileChooser.APPROVE_OPTION) {
				File file = choosefile1.getSelectedFile();
				absolutePath = file.getAbsolutePath();
				t1.addPicturePath(absolutePath);
				// WHAT ARE WE GOING TO DO ONCE PICTUREFILE IS SELECTED.
				// Inserted code HERE:
				terminal1.setText("");
				terminal1.append("Congratulations! Your Picture: "
						+ file.getName()
						+ " has been successfully opened.\nAbsPath:"
						+ absolutePath + "\n");
			}
			terminal1.setCaretPosition(terminal1.getDocument().getLength());
			// Activity1 picture

		} else if (e.getSource() == insertPicButton1) {

			returnVal = choosefile2
					.showOpenDialog(InteractiveTaskCardsGUI.this);

			if (returnVal == JFileChooser.APPROVE_OPTION) {
				File file = choosefile2.getSelectedFile();
				absolutePath = file.getAbsolutePath();
				t1.act1.insertpicPath(absolutePath);
				// WHAT ARE WE GOING TO DO ONCE PICTUREFILE IS SELECTED.
				// Inserted code HERE:
				act1file = file.getName();

				terminal2
						.append("Your Picture: "
								+ file.getName()
								+ " has been successfully opened for activity 1.\nAbsPath:"
								+ absolutePath + "\n");

			}
			terminal2.setCaretPosition(terminal2.getDocument().getLength());

		} else if (e.getSource() == insertPicButton2) {

			returnVal = choosefile3
					.showOpenDialog(InteractiveTaskCardsGUI.this);

			if (returnVal == JFileChooser.APPROVE_OPTION) {
				File file = choosefile3.getSelectedFile();
				absolutePath = file.getAbsolutePath();
				t1.act2.insertpicPath(absolutePath);
				// WHAT ARE WE GOING TO DO ONCE PICTUREFILE IS SELECTED.
				// Inserted code HERE:
				act2file = file.getName();
				terminal3
						.append("Your Picture: "
								+ file.getName()
								+ " has been successfully opened for activity 2.\nAbsPath:"
								+ absolutePath + "\n");
			}
			terminal3.setCaretPosition(terminal3.getDocument().getLength());

		} else if (e.getSource() == insertPicButton3) {

			returnVal = choosefile4
					.showOpenDialog(InteractiveTaskCardsGUI.this);

			if (returnVal == JFileChooser.APPROVE_OPTION) {
				File file = choosefile4.getSelectedFile();
				absolutePath = file.getAbsolutePath();
				t1.act3.insertpicPath(absolutePath);
				// WHAT ARE WE GOING TO DO ONCE PICTUREFILE IS SELECTED.
				// Inserted code HERE:

				act3file = file.getName();
				terminal4
						.append("Your Picture: "
								+ file.getName()
								+ " has been successfully opened for activity 3.\nAbsPath:"
								+ absolutePath + "\n");
			}
			terminal4.setCaretPosition(terminal4.getDocument().getLength());

		} else if (e.getSource() == insertPicButton4) {

			returnVal = choosefile5
					.showOpenDialog(InteractiveTaskCardsGUI.this);

			if (returnVal == JFileChooser.APPROVE_OPTION) {
				File file = choosefile5.getSelectedFile();
				absolutePath = file.getAbsolutePath();
				t1.act4.insertpicPath(absolutePath);
				// WHAT ARE WE GOING TO DO ONCE PICTUREFILE IS SELECTED.
				// Inserted code HERE:
				act4file = file.getName();
				terminal5
						.append("Your Picture: "
								+ file.getName()
								+ " has been successfully opened for activity 4.\nAbsPath:"
								+ absolutePath + "\n");
			}
			terminal5.setCaretPosition(terminal5.getDocument().getLength());

		} else if (e.getSource() == insertPicButton5) {

			returnVal = choosefile6
					.showOpenDialog(InteractiveTaskCardsGUI.this);

			if (returnVal == JFileChooser.APPROVE_OPTION) {
				File file = choosefile6.getSelectedFile();
				absolutePath = file.getAbsolutePath();
				t1.act5.insertpicPath(absolutePath);
				// WHAT ARE WE GOING TO DO ONCE PICTUREFILE IS SELECTED.
				// Inserted code HERE:
				act5file = file.getName();
				terminal6
						.append("Your Picture: "
								+ file.getName()
								+ " has been successfully opened for activity 5.\nAbsPath:"
								+ absolutePath + "\n");
			}
			terminal6.setCaretPosition(terminal6.getDocument().getLength());

		}else if(e.getSource() == insertLink1){
			JTextField linkBox = new JTextField(30);
			Object[] options = { "Done", "Cancel" };
			String msg = "Inert a link you would like to embed";
			Object[] array = { msg, linkBox };
			int n = JOptionPane.showOptionDialog(pagesPanel, array,
					":::::::::", JOptionPane.YES_NO_OPTION,
					JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
			// Cancel selected
			if (n == JOptionPane.NO_OPTION) {
				// Do nothing
			} else {
				// This is where I want it to do somethign
			
				String s = linkBox.getText();

				String b = "<a href=\\\"" + s +"\\\">Link</a>";
				activity1Box.append(b);
	
				System.out.println(b);
		}
		}
		else if(e.getSource() == insertLink2){
			JTextField linkBox = new JTextField(30);
			Object[] options = { "Done", "Cancel" };
			String msg = "Insert a link you would like to embed";
			Object[] array = { msg, linkBox };
			int n = JOptionPane.showOptionDialog(pagesPanel, array,
					":::::::::", JOptionPane.YES_NO_OPTION,
					JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
			// Cancel selected
			if (n == JOptionPane.NO_OPTION) {
				// Do nothing
			} else {
				// This is where I want it to do somethign
			
				String s = linkBox.getText();

				String b = "<a href=\\\"" + s +"\\\">Link</a>";
				activity2Box.append(b);
				
				System.out.println(b);
		}
		}
		else if(e.getSource() == insertLink3){
			JTextField linkBox = new JTextField(30);
			Object[] options = { "Done", "Cancel" };
			String msg = "Insert a link you would like to embed";
			Object[] array = { msg, linkBox };
			int n = JOptionPane.showOptionDialog(pagesPanel, array,
					":::::::::", JOptionPane.YES_NO_OPTION,
					JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
			// Cancel selected
			if (n == JOptionPane.NO_OPTION) {
				// Do nothing
			} else {
				// This is where I want it to do somethign
			
				String s = linkBox.getText();

				String b = "<a href=\\\"" + s +"\\\">Link</a>";
				activity3Box.append(b);
				
				System.out.println(b);
		}
		}
		else if(e.getSource() == insertLink4){
			JTextField linkBox = new JTextField(30);
			Object[] options = { "Done", "Cancel" };
			String msg = "Insert a link you would like to embed";
			Object[] array = { msg, linkBox };
			int n = JOptionPane.showOptionDialog(pagesPanel, array,
					":::::::::", JOptionPane.YES_NO_OPTION,
					JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
			// Cancel selected
			if (n == JOptionPane.NO_OPTION) {
				// Do nothing
			} else {
				// This is where I want it to do somethign
			
				String s = linkBox.getText();

				String b = "<a href=\\\"" + s +"\\\">Link</a>";
				activity4Box.append(b);
				
				System.out.println(b);
		}
		}
		else if(e.getSource() == insertLink5){
			JTextField linkBox = new JTextField(30);
			Object[] options = { "Done", "Cancel" };
			String msg = "Insert a link you would like to embed";
			Object[] array = { msg, linkBox };
			int n = JOptionPane.showOptionDialog(pagesPanel, array,
					":::::::::", JOptionPane.YES_NO_OPTION,
					JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
			// Cancel selected
			if (n == JOptionPane.NO_OPTION) {
				// Do nothing
			} else {
				// This is where I want it to do somethign
			
				String s = linkBox.getText();

				String b = "<a href=\\\"" + s +"\\\">Link</a>";
				activity5Box.append(b);
				System.out.println(b);
		}
		}

		else if (e.getSource() == embedWebButton1) {
			JTextField embedBox = new JTextField(30);
			Object[] options = { "Done", "Cancel" };
			String msg = "Copy and Paste the Website URL you wish to embed\n*NOTE: By selecting this option any YOUTUBE or Map Content Will Be Deleted from this card.\nIt is not advised to put any other content on this activity\n";
			Object[] array = { msg, embedBox };
			int n = JOptionPane.showOptionDialog(pagesPanel, array,
					":::::::::", JOptionPane.YES_NO_OPTION,
					JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
			// Cancel selected
			if (n == JOptionPane.NO_OPTION) {
				// Do nothing
			} else {
				// This is where I want it to do somethign
				String s = embedBox.getText();
				if(s.length()>2){terminal2
						.append("\nYou have Successfully embedded a Webpage");
				

				String b = "<iframe id=\\\"innerContent\\\" onload = \\\"resize();\\\" src=\\\"" + s +"\\\"><\\iframe>";

				t1.act1.insertVideoPath(b);
				System.out.println(b);
				}

			}

		}
		else if (e.getSource() == embedWebButton2) {
			JTextField embedBox = new JTextField(30);
			Object[] options = { "Done", "Cancel" };
			String msg = "Copy and Paste the Website URL you wish to embed\n*NOTE: By selecting this option any YOUTUBE or Map Content Will Be Deleted from this card.\nIt is not advised to put any other content on this activity\n";
			Object[] array = { msg, embedBox };
			int n = JOptionPane.showOptionDialog(pagesPanel, array,
					":::::::::", JOptionPane.YES_NO_OPTION,
					JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
			// Cancel selected
			if (n == JOptionPane.NO_OPTION) {
				// Do nothing
			} else {
				// This is where I want it to do somethign
				String s = embedBox.getText();
				if(s.length()>2){terminal3
						.append("\nYou have Successfully embedded a Webpage");
				

				String b = "<iframe id=\\\"innerContent\\\" onload = \\\"resize();\\\" src=\\\"" + s +"\\\"><\\iframe>";

				t1.act2.insertVideoPath(b);
				System.out.println(b);
				}

			}

		}
		else if (e.getSource() == embedWebButton3) {
			JTextField embedBox = new JTextField(30);
			Object[] options = { "Done", "Cancel" };
			String msg = "Copy and Paste the Website URL you wish to embed\n*NOTE: By selecting this option any YOUTUBE or Map Content Will Be Deleted from this card.\nIt is not advised to put any other content on this activity\n";
			Object[] array = { msg, embedBox };
			int n = JOptionPane.showOptionDialog(pagesPanel, array,
					":::::::::", JOptionPane.YES_NO_OPTION,
					JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
			// Cancel selected
			if (n == JOptionPane.NO_OPTION) {
				// Do nothing
			} else {
				// This is where I want it to do somethign
				String s = embedBox.getText();
				if(s.length()>2){terminal4
						.append("\nYou have Successfully embedded a Webpage");
				

				String b = "<iframe id=\\\"innerContent\\\" onload = \\\"resize();\\\" src=\\\"" + s +"\\\"><\\iframe>";

				t1.act3.insertVideoPath(b);
				System.out.println(b);
				}

			}

		}
		else if (e.getSource() == embedWebButton4) {
			JTextField embedBox = new JTextField(30);
			Object[] options = { "Done", "Cancel" };
			String msg = "Copy and Paste the Website URL you wish to embed\n*NOTE: By selecting this option any YOUTUBE or Map Content Will Be Deleted from this card.\nIt is not advised to put any other content on this activity\n";
			Object[] array = { msg, embedBox };
			int n = JOptionPane.showOptionDialog(pagesPanel, array,
					":::::::::", JOptionPane.YES_NO_OPTION,
					JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
			// Cancel selected
			if (n == JOptionPane.NO_OPTION) {
				// Do nothing
			} else {
				// This is where I want it to do somethign
				String s = embedBox.getText();
				if(s.length()>2){terminal5
						.append("\nYou have Successfully embedded a Webpage");
				

				String b = "<iframe id=\\\"innerContent\\\" onload = \\\"resize();\\\" src=\\\"" + s +"\\\"><\\iframe>";

				t1.act4.insertVideoPath(b);
				System.out.println(b);
				}

			}

		}
		else if (e.getSource() == embedWebButton5) {
			JTextField embedBox = new JTextField(30);
			Object[] options = { "Done", "Cancel" };
			String msg = "Copy and Paste the Website URL you wish to embed\n*NOTE: By selecting this option any YOUTUBE or Map Content Will Be Deleted from this card.\nIt is not advised to put any other content on this activity\n";
			Object[] array = { msg, embedBox };
			int n = JOptionPane.showOptionDialog(pagesPanel, array,
					":::::::::", JOptionPane.YES_NO_OPTION,
					JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
			// Cancel selected
			if (n == JOptionPane.NO_OPTION) {
				// Do nothing
			} else {
				// This is where I want it to do somethign
				String s = embedBox.getText();
				if(s.length()>2){terminal6
						.append("\nYou have Successfully embedded a Webpage");
				

				String b = "<iframe id=\\\"innerContent\\\" onload = \\\"resize();\\\" src=\\\"" + s +"\\\"><\\iframe>";
				
				t1.act5.insertVideoPath(b);
				System.out.println(b);
				}

			}

		}
		

		
		
		
		else if (e.getSource() == insertVideoButton1) {
			System.out.println("I GOT HERE askldjfalsdkfj");
			JTextField youtubebox = new JTextField(30);
			Object[] options = { "Update", "Cancel" };
			String msg = "*For Youtube:Select the Share button under the YouTube video you would like.\n Select Embed.\n Copy the code provided into the box.\n\n*For Maps: Find the route you wish to embed.\n Click the embed button\n Copy and paste the source\n";
			Object[] array = { msg, youtubebox };
			int n = JOptionPane.showOptionDialog(pagesPanel, array,
					":::::::::", JOptionPane.YES_NO_OPTION,
					JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
			// Cancel selected
			if (n == JOptionPane.NO_OPTION) {
				// Do nothing
			} else {
				// This is where I want it to do somethign
				String s = youtubebox.getText();
				if(s.length()>2){terminal2
						.append("\nYou have Successfully Selected a YouTube Video for this Activity.\n");
				

				String b = s.replaceAll("\"", "\\\\\"");

				t1.act1.insertVideoPath(b);
				System.out.println(b);
				}

			}

		}

		else if (e.getSource() == insertVideoButton2) {

			JTextField youtubebox2 = new JTextField(30);
			Object[] options = { "Update", "Cancel" };
			String msg = "*For Youtube:Select the Share button under the YouTube video you would like.\n Select Embed.\n Copy the code provided into the box.\n\n*For Maps: Find the route you wish to embed.\n Click the embed button\n Copy and paste the source\n";
			Object[] array = { msg, youtubebox2 };
			int n = JOptionPane.showOptionDialog(pagesPanel, array,
					":::::::::", JOptionPane.YES_NO_OPTION,
					JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
			// Cancel selected
			if (n == JOptionPane.NO_OPTION) {
				// Do nothing
			} else {
				// This is where I want it to do somethign
				String s = youtubebox2.getText();
				if(s.length()>2){terminal3
						.append("\nYou have Successfully Selected a YouTube Video for this Activity.\n");
				

				String b = s.replaceAll("\"", "\\\\\"");

				t1.act2.insertVideoPath(b);
				System.out.println(b);
				}

			}

		} else if (e.getSource() == insertVideoButton3) {

			JTextField youtubebox3 = new JTextField(30);
			Object[] options = { "Update", "Cancel" };
			String msg = "*For Youtube:Select the Share button under the YouTube video you would like.\n Select Embed.\n Copy the code provided into the box.\n\n*For Maps: Find the route you wish to embed.\n Click the embed button\n Copy and paste the source\n";
			Object[] array = { msg, youtubebox3 };
			int n = JOptionPane.showOptionDialog(pagesPanel, array,
					":::::::::", JOptionPane.YES_NO_OPTION,
					JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
			// Cancel selected
			if (n == JOptionPane.NO_OPTION) {
				// Do nothing
			} else {
				// This is where I want it to do somethign
				String s = youtubebox3.getText();
				if(s.length()>2){terminal4
						.append("\nYou have Successfully Selected a YouTube Video for this Activity.\n");
				

				String b = s.replaceAll("\"", "\\\\\"");

				t1.act3.insertVideoPath(b);
				System.out.println(b);
				}
			}
		} else if (e.getSource() == insertVideoButton4) {

			JTextField youtubebox4 = new JTextField(30);
			Object[] options = { "Update", "Cancel" };
			String msg = "*For Youtube:Select the Share button under the YouTube video you would like.\n Select Embed.\n Copy the code provided into the box.\n\n*For Maps: Find the route you wish to embed.\n Click the embed button\n Copy and paste the source\n";
			Object[] array = { msg, youtubebox4 };
			int n = JOptionPane.showOptionDialog(pagesPanel, array,
					":::::::::", JOptionPane.YES_NO_OPTION,
					JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
			// Cancel selected
			if (n == JOptionPane.NO_OPTION) {
				// Do nothing
			} else {
				// This is where I want it to do somethign
				String s = youtubebox4.getText();
				if(s.length()>2){terminal5
						.append("\nYou have Successfully Selected a YouTube Video for this Activity.\n");
				

				String b = s.replaceAll("\"", "\\\\\"");

				t1.act4.insertVideoPath(b);
				System.out.println(b);
				}

			}

		} else if (e.getSource() == insertVideoButton5) {

			JTextField youtubebox5 = new JTextField(30);
			Object[] options = { "Update", "Cancel" };
			String msg = "*For Youtube:Select the Share button under the YouTube video you would like.\n Select Embed.\n Copy the code provided into the box.\n\n*For Maps: Find the route you wish to embed.\n Click the embed button\n Copy and paste the source\n";
			Object[] array = { msg, youtubebox5 };
			int n = JOptionPane.showOptionDialog(pagesPanel, array,
					":::::::::", JOptionPane.YES_NO_OPTION,
					JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
			// Cancel selected
			if (n == JOptionPane.NO_OPTION) {
				// Do nothing
			} else {
				// This is where I want it to do somethign
				String s = youtubebox5.getText();
				if(s.length()>2){terminal6
						.append("\nYou have Successfully Selected a YouTube Video for this Activity.\n");
				

				String b = s.replaceAll("\"", "\\\\\"");

				t1.act5.insertVideoPath(b);
				System.out.println(b);
				}

			}

		}

		else if (e.getSource() == next1) {

			if (t1.picPath == null) {
				terminal1.setText("");
				terminal1.append("You must insert a picture to continues!");
				fullLayout.show(pagesPanel, "Page2a");
			} else {

				fullLayout.show(pagesPanel, "Page2b");
			}
		} else if (e.getSource() == next1b) {
			// About me info
			if (resumetask) {
				Object[] options = { "Update", "Continue" };
				int n = JOptionPane
						.showOptionDialog(
								pagesPanel,
								"You previously selected "
										+ t1.numActivities
										+ " activities. Would You like to update?",
								":::::::::", JOptionPane.YES_NO_OPTION,
								JOptionPane.QUESTION_MESSAGE, null, options,
								options[1]);

				// Continue selected
				if (n == JOptionPane.NO_OPTION) {
					fullLayout.show(pagesPanel, "Page4");
					switch (t1.numActivities) {
					case 1:
						t1.createOne();
						break;
					case 2:
						t1.createTwo();
						break;
					case 3:
						t1.createThree();
						break;
					case 4:

						t1.createFour();
						break;
					case 5:

						t1.createFive();
						break;
					default:

					}
				} else {
					fullLayout.show(pagesPanel, "Page3");
				}
			} else {
				fullLayout.show(pagesPanel, "Page3");
			}
		} else if (e.getSource() == previous1b)
			fullLayout.show(pagesPanel, "Page2");

		else if (e.getSource() == previous2)
			fullLayout.show(pagesPanel, "Page2");
		else if (e.getSource() == button1) {
			numActivities = 1;
			t1.numActivities = 1;
			t1.createOne();
			fullLayout.show(pagesPanel, "Page4");
		} else if (e.getSource() == button2) {
			numActivities = 2;
			t1.numActivities = 2;
			t1.createTwo();
			fullLayout.show(pagesPanel, "Page4");
		} else if (e.getSource() == button3) {
			numActivities = 3;
			t1.numActivities = 3;
			t1.createThree();
			fullLayout.show(pagesPanel, "Page4");
		} else if (e.getSource() == button4) {
			numActivities = 4;
			t1.numActivities = 4;
			t1.createFour();
			fullLayout.show(pagesPanel, "Page4");
		} else if (e.getSource() == button5) {
			numActivities = 5;
			t1.numActivities = 5;
			t1.createFive();

			fullLayout.show(pagesPanel, "Page4");

		} else if (e.getSource() == next3) {
			if (numActivities == 1) {

				fullLayout.show(pagesPanel, "Page9");
			} else
				// now on activity2
				fullLayout.show(pagesPanel, "Page5");
		} else if (e.getSource() == previous3)
			fullLayout.show(pagesPanel, "Page3");

		else if (e.getSource() == next4) {
			if (numActivities == 2)
				fullLayout.show(pagesPanel, "Page9");
			else
				// now on activity3
				fullLayout.show(pagesPanel, "Page6");
		} else if (e.getSource() == previous4)
			fullLayout.show(pagesPanel, "Page4");

		else if (e.getSource() == next5) {
			if (numActivities == 3)
				fullLayout.show(pagesPanel, "Page9");
			else
				// now on activity4
				fullLayout.show(pagesPanel, "Page7");
		} else if (e.getSource() == previous5)
			fullLayout.show(pagesPanel, "Page5");

		else if (e.getSource() == next6) {
			if (numActivities == 4)
				fullLayout.show(pagesPanel, "Page9");
			else
				// now on activity5
				fullLayout.show(pagesPanel, "Page8");
		} else if (e.getSource() == previous6)
			fullLayout.show(pagesPanel, "Page6");

		else if (e.getSource() == next7) {

			fullLayout.show(pagesPanel, "Page9");
		} else if (e.getSource() == previous7)
			fullLayout.show(pagesPanel, "Page7");
		else if (e.getSource() == previous8) {
			switch (numActivities) {
			case 1:
				fullLayout.show(pagesPanel, "Page4");
				break;
			case 2:
				fullLayout.show(pagesPanel, "Page5");
				break;
			case 3:
				fullLayout.show(pagesPanel, "Page6");
				break;
			case 4:
				fullLayout.show(pagesPanel, "Page7");
				break;
			default:
				fullLayout.show(pagesPanel, "Page8");
				break;
			}
		} else if (e.getSource() == saveExit) {

			String temp = aboutText.getText();
			String temp2 = convert(temp);
			temp = replaceWithStar(temp2);

			t1.addAboutMe(temp);
			System.out.println("ABOUT" + aboutText.getText());
			t1.act1.insertHeader(replaceWithStar(titleBox1.getText()));
			t1.act1.insertText(replaceWithStar(activity1Box.getText()));
			System.out.println("I gott here");
			if (numActivities >= 2)
				t1.act2.insertHeader(replaceWithStar(titleBox2.getText()));
				t1.act2.insertText(replaceWithStar(activity2Box.getText()));
			if (numActivities >= 3)
				t1.act3.insertHeader(replaceWithStar(titleBox3.getText()));
				t1.act3.insertText(replaceWithStar(activity3Box.getText()));
			if (numActivities >= 4)
				t1.act4.insertHeader(replaceWithStar(titleBox4.getText()));
				t1.act4.insertText(replaceWithStar(activity4Box.getText()));
			if (numActivities >= 5)
				t1.act5.insertHeader(replaceWithStar(titleBox5.getText()));
				t1.act5.insertText(replaceWithStar(activity5Box.getText()));

			String path = ".//TaskCards\\" + t1.fileName;
			File nameFile = new File(path);
			try {
				FileOutputStream out = new FileOutputStream(nameFile);
				out.write(t1.toString(numActivities).getBytes());
			} catch (FileNotFoundException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			} catch (IOException f) {
				// TODO Auto-generated catch block
				f.printStackTrace();
			}

			System.exit(ABORT);

		}

		else if (e.getSource() == export) {

			String temp = aboutText.getText();
			temp = replaceWithStar(temp);
			String temp2 = convert(temp);
			String temp3 = temp2.replaceAll("[\"]","\\\\\"");
			String temp4 = temp3.replaceAll("[*]","<br>");
			System.out.println("HERE:" + temp4);
			t1.addAboutMe(temp4);
			System.out.println("ABOUT" + aboutText.getText());
			t1.act1.insertText(convert(replaceWithStar(activity1Box.getText())));
			t1.act1.insertHeader(convert(replaceWithStar(titleBox2.getText())));

			if (numActivities >= 2){
				t1.act2.insertText(convert(replaceWithStar(activity2Box.getText())));
				t1.act2.insertHeader(convert(replaceWithStar(titleBox2.getText())));
			}
			if (numActivities >= 3){
				t1.act3.insertText(convert(replaceWithStar(activity3Box.getText())));
				t1.act3.insertHeader(convert(replaceWithStar(titleBox3.getText())));
			}
			if (numActivities >= 4){
				t1.act4.insertText(convert(replaceWithStar(activity4Box.getText())));
				t1.act4.insertHeader(convert(replaceWithStar(titleBox4.getText())));
			}
			if (numActivities >= 5){
				t1.act5.insertText(convert(replaceWithStar(activity5Box.getText())));
				t1.act5.insertHeader(convert(replaceWithStar(titleBox5.getText())));
			}

			String pathToDirectory = createDirectory(t1.fileName + "TaskCard");
			if (pathToDirectory != null)
				pathToDirectory += "\\";
			else {
				pathToDirectory = System.getProperty("user.home")
						+ "\\Desktop\\" + t1.fileName + "TaskCard\\";

			}

			System.out.println("Path to Directory" + pathToDirectory);

			File userImage = new File(t1.picPath);
			String userImagePath = userImage.getAbsolutePath();
			int period = t1.picPath.lastIndexOf(".");
			String ext = t1.picPath.substring(period);
			String outputFileName = t1.fileName + ext;
			// CHANGE:
			copyImage(userImagePath, pathToDirectory, outputFileName);

			// House Image

			File house = new File(".\\images\\HOUSE.png");
			String housePath = house.getAbsolutePath();
			System.out.println("pathtodirectory: " + pathToDirectory);
			copyImage(housePath, pathToDirectory, "HOUSE.png");

			// Next image
			File next = new File(".\\images\\next.png");
			String nextPath = next.getAbsolutePath();
			copyImage(nextPath, pathToDirectory, "next.png");

			// Previous image
			File previous = new File(".\\images\\prev.png");
			String previousPath = previous.getAbsolutePath();
			copyImage(previousPath, pathToDirectory, "prev.png");

			// Now the Html file blehhh
			// Get Info
			HTML html1 = new HTML();
			html1.createHead(t1.name);
			html1.createBody(t1.name, outputFileName);
			String Html = html1.toString();

			// Send to HTML File

			String path2 = pathToDirectory + t1.fileName + ".html";
			File nameFile2 = new File(path2);
			try {
				FileOutputStream out2 = new FileOutputStream(nameFile2);
				out2.write(Html.getBytes());
			} catch (FileNotFoundException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			} catch (IOException f) {
				// TODO Auto-generated catch block
				f.printStackTrace();
			}

			// Now the CSS file bleh
			CSS css1 = new CSS();
			String css = css1.toString();

			// Send to CSS File
			String path3 = pathToDirectory + "style.css";
			File nameFile3 = new File(path3);
			try {
				FileOutputStream out3 = new FileOutputStream(nameFile3);
				out3.write(css.getBytes());
			} catch (FileNotFoundException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			} catch (IOException f) {
				// TODO Auto-generated catch block
				f.printStackTrace();
			}

			// Now the icky Javascript
			JavaScript js1 = new JavaScript();
			js1.insertContent("About Me", t1.aboutMe);

			// GET ACTIVITY PICS
			String tempp = "";
			if (t1.act1.picPath != null) {

				File act1Image = new File(t1.act1.picPath);
				String act1ImagePath = act1Image.getAbsolutePath();
				System.out.println("HERE" + act1file);
				copyImage(act1ImagePath, pathToDirectory, act1file);
				numImages++;
				tempp = "<img src=\\\"" + act1file
						+ "\\\" alt =\\\"Activity 1\\\"/><br>";

			}
			if (!t1.act1.textInformation.isEmpty()) {
				tempp += t1.act1.textInformation;
			}
			if (t1.act1.videoPath != null) {
				System.out.println("I did get here");
				tempp += t1.act1.returnVideoPath();
			}
			
			// HeaderTest1
			js1.insertContent(t1.act1.headerInformation, tempp);

			if (numActivities >= 2) {
				String tempp2 = "";
				if (t1.act2.picPath != null) {

					File act2Image = new File(t1.act2.picPath);
					String act2ImagePath = act2Image.getAbsolutePath();
					System.out.println("HERE" + act2file);
					copyImage(act2ImagePath, pathToDirectory, act2file);
					numImages++;
					tempp2 = "<img src=\\\"" + act2file
							+ "\\\" alt =\\\"Activity 2\\\"/><br>";

				}

				if (!t1.act2.textInformation.isEmpty()) {
					tempp2 += t1.act2.textInformation;
				}
				if (t1.act2.videoPath != null) {
					System.out.println("I did get here");
					tempp2 += t1.act2.returnVideoPath();
				}
				
				// HeaderTest2
				js1.insertContent(t1.act2.headerInformation, tempp2);
			}

			if (numActivities >= 3) {
				String tempp3 = "";
				if (t1.act3.picPath != null) {

					File act3Image = new File(t1.act3.picPath);
					String act3ImagePath = act3Image.getAbsolutePath();
					System.out.println("HERE" + act3file);
					copyImage(act3ImagePath, pathToDirectory, act3file);
					numImages++;
					tempp3 = "<img src=\\\"" + act3file
							+ "\\\" alt =\\\"Activity 3\\\"/><br>";

				}
				if (!t1.act3.textInformation.isEmpty()) {
					tempp3 += t1.act3.textInformation;
				}
				if (t1.act3.videoPath != null) {
					System.out.println("I did get here");
					tempp3 += t1.act3.returnVideoPath();
				}
				
				// HeaderTest3
				js1.insertContent(t1.act3.headerInformation, tempp3);
			}

			if (numActivities >= 4) {
				String tempp4 = "";
				if (t1.act4.picPath != null) {

					File act4Image = new File(t1.act4.picPath);
					String act4ImagePath = act4Image.getAbsolutePath();
					System.out.println("HERE" + act4file);
					copyImage(act4ImagePath, pathToDirectory, act4file);
					numImages++;
					tempp4 = "<img src=\\\"" + act4file
							+ "\\\" alt =\\\"Activity 4\\\"/><br>";

				}
				if (!t1.act4.textInformation.isEmpty()) {
					tempp4 += t1.act4.textInformation;
				}
				if (t1.act4.videoPath != null) {
					System.out.println("I did get here");
					tempp4 += t1.act4.returnVideoPath();
				}
				
				// HeaderTest4
				js1.insertContent(t1.act4.headerInformation, tempp4);
			}

			if (numActivities == 5) {
				String tempp5 = "";
				if (t1.act5.picPath != null) {

					File act5Image = new File(t1.act5.picPath);
					String act5ImagePath = act5Image.getAbsolutePath();
					System.out.println("HERE" + act5file);
					copyImage(act5ImagePath, pathToDirectory, act5file);
					numImages++;
					tempp5 = "<img src=\\\"" + act5file
							+ "\\\" alt =\\\"Activity 5\\\"/><br>";

				}
				if (!t1.act5.textInformation.isEmpty()) {
					tempp5 += t1.act5.textInformation;
				}
				if (t1.act5.videoPath != null) {
					System.out.println("I did get here");
					tempp5 += t1.act5.returnVideoPath();
				}
				
				// HeaderTest5
				js1.insertContent(t1.act5.headerInformation, tempp5);
			}

			String js = js1.toString();

			// Send to js File
			String path4 = pathToDirectory + "script.js";
			File nameFile4 = new File(path4);
			try {
				FileOutputStream out4 = new FileOutputStream(nameFile4);
				out4.write(js.getBytes());
			} catch (FileNotFoundException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			} catch (IOException f) {
				// TODO Auto-generated catch block
				f.printStackTrace();
			}

			String path = ".//TaskCards\\" + t1.fileName;

			File nameFile = new File(path);
			try {
				FileOutputStream out = new FileOutputStream(nameFile);
				out.write(t1.toString(numActivities).getBytes());
			} catch (FileNotFoundException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			} catch (IOException f) {
				// TODO Auto-generated catch block
				f.printStackTrace();
			}
			System.out.println(t1.toString(numActivities));
			System.exit(ABORT);

		}

	}

	public static void makeGUI() {

		JFrame frame1 = new JFrame("Interactive Task Cards");
		frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		InteractiveTaskCardsGUI test = new InteractiveTaskCardsGUI();
		test.addComponent(frame1.getContentPane());

		frame1.setMinimumSize(new Dimension(450, 450));
		frame1.setResizable(false);
		frame1.setVisible(true);

	}

	public static void main(String[] args) {

		EventQueue.invokeLater(new Runnable() {

			public void run() {

				makeGUI();
			}
		});

	}

}
